/**
 * 字符串中是否包含有`DFS`或者`dfs`的子序列
 * 设置标记即可
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;


using llt = long long;
using Real = double;
using vi = vector<int>;
using pii = pair<int, int>;

int N;
string S;

void proc(){
    int a = 0, b = 0;
    for(auto c : S){
        if('D' == c and 0 == a){
            a = 1;
        }
        if('d' == c and 0 == b){
            b = 1;
        }
        if('F' == c and 1 == a){
            a = 2;
        }
        if('f' == c and 1 == b){
            b = 2;
        }
        if('S' == c and 2 == a){
            a = 3;
        }
        if('s' == c and 2 == b){
            b = 3;
        }
    }
    cout << (a == 3 ? 1 : 0) << " " << (b == 3 ? 1 : 0) << "\n";
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0);
    int nofkase = 1;
    cin >> nofkase;
    while(nofkase--){
        cin >> N >> S;
        proc();
    }
    return 0;
}